SW Economy by Stranger

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.
You are free to use and distribute this OXP on non-commercial basis. 
Rebundling of this OXP within another distribution is permitted as long as it is unchanged.
Any mods/derivatives of this OXP must be distributed under another names.
The license information (either as this file or merged into a larger one) must be included in the OXP.

--------------------------------------------------------------

This OXZ was originally part of bundled OXP, containing six main packages:

� SW Economy
� SW Equipment
� SW Shipdata
� SW Population
� SW Resident Filter
� (e)Xternal OXP tweaks

Since version 3.8 these OXPs are separated and presented as individual packages in OXZ format.

*****

First, this OXP changes canonic descriptor of system economy (text string Poor Agricultural, for example, used only to display on F7 system info screen, Oolite uses for market calculations numeric value system.economy = 7).
New economic classification implemented:

Poor Agricultural	->	Extreme Agricultural
Average Agricultural	->	Strong Agricultural
Rich Agricultural	->	Common Agricultural
Mainly Agricultural	->	Mainly Agricultural
Mainly Industrial	->	Mainly Industrial
Poor Industrial		->	Common Industrial
Average Industrial	->	Strong Industrial
Rich Industrial		->	Extreme Industrial

It also describes three new trade items: fresh water, oxygen and medicine.
New rebalanced set of market rules is implemented. Most items has the same economic values with rebalanced properties, but price for some items (food, textile, slaves) readjusted.
Quantity of luxuries and narcotics is redefined in kg, not tons.

SW Economy set system market with system-specific filters:

	� Computers, machinery and alloys are not available in agrarian systems
	� Food, textiles, wines and furs are not available in industrial systems
	� Food, textiles, wines and furs are not available in agricultural systems with archaic TL AND main planet radius below 5425 km
	� Computers, medicine and luxuries available only in systems above median tech level, quantity is limited
	� Machinery, alloys and oxygen available only in systems above low tech level
	� Minerals and radioactive available only in low-tech OR industrial systems
	� Machinery is more profitable in comparison with default market
	� Textiles are more profitable in comparison with default market
	� Quantity of some items depends of system gross productivity
	� Illegal items available only in low-tech unstable systems
	� and some more readjustments

Modified spara's In-System Market Restore script included to provide saving of market with additional items (fresh water, oxygen and medicine). Modifications includes adding extra items and changing item order in commodity array.

SW Economy set also new market definitions for secondary ports, overriding market definitions in external packages:

Anarchies
	� Salvage Gang
	� Hackers Outpost
	� Renegade Station
Commies
	� Astrogulag Penal Colony
	� CZGF
	� SLAPU
Dictators
	� Astrofactory
Galactic Navy
	� Navy Station
Deep Space Dredgers
	� Dredgers

These original OXPs has scripts, emulating obsolete market definition using commodities.plist (was replaced with trade-goods.plist since Oolite 1.82). These scripts can override SW Economy market definitions for secondary ports, but in worst case you'll just have emulated old markets. Not conflicting with SW Economy model, just unbalanced with my altered prices.

Known issues

New economic rules will activates only AFTER first hyperjump to new system. Starting as new pilot on Lave you'll have F8 screen with old goods list and with old price/quantity settings. This is intentionally decision. There are possible multiple events like departing from station(s) or docking with station(s) staying in system, but only one event of entering this system. So it is safe to set market for system at arrival once to avoid recurring loops. New market state will be stored in your first save in new system.

After installing this OXP you'll can't get new market rules until you'll leave your current system, so playing custom scenario using ship, not equipped with hyperdrive (such Bushmaster in Advanced miner scenario), you'll have vanilla market. Lave is not suitable system for mining business and it is wise to leave Lave ASAP taking advice to use wormhole of friendly trader ship. After arriving to new system you'll have new economy. But if you'll install this OXP after entering new system, having ship without hyperdrive you'll get stuck in vanilla market until you'll find way to leave this system.

Starting new pilot is good idea in any case, but I think it is not obligatory. Hope it is safe to try new rules having existent saves, but I recommend to backup your current save.

If you'll decide to uninstall this OXP it is good to sell all extra goods (fresh water, oxygen and medicine) first. Extra goods will remain in system market, generating error message in log, but this issue will be fixed after entering new system.

Be careful with luxuries and narcotics! Having 50 kg of luxuries on 10-ton Cobra Mk I is safe, but deinstalling this OXP you'll convert this 50 kg to 50 tons and lose extra 40 tons of these items!

As I already mentioned scripts for secondary ports in original OXPs defines goods quantities using vanilla rules, so I'll be grateful to you for feedback.

Changed economy descriptions will not affect any Oolite scripts. Text string Extreme Agricultural, for example, used only to display on F7 system info screen, Oolite uses for market calculations numeric value system.economy = 7.

Enjoy!

Credits:
In-System Market Restore (author spara)
Anarchies (authors Commander McLane, Killer Wolf, Arexack Heretic, Eric Walch, spara, Norby, phkb and Griff)
Commies (authors Amaranth, Dr. Nil, Eric Walch, Norby, phkb)
Dictators (authors Ramirez, gsagostinho, phkb, Griff)
Galactic Navy (author Nemoricus)
Deep Space Dredger (authors Sabre, Eric Walch, Little Bear, Captain Berf)
Seven - detecting error in trade-goods.plist

phkb's Tweak
============
The problem with changing market information in the shipExitedWitchspace function, is that any code that tries to read sample commodity information from another system will not have those changes applied. So, estimating the potential cost/benefit of a particular cargo run becomes impossible.

This tweak moves the market changes to be inside the market definition, making all the changes visible for any system, at any time.

At the same time, at the prompting of Cholmondely, some tweaks were made to the "harsh mining" systems (ie. systems with archaic tech and planet radii below 5425km). Rather than completely wiping out all agriculture-related commodities, instead we reduce the quantities available. The amount they are reduced by is tweakable via settings.

Coupled with this, is a small boost to the amount of mining goods available at those systems, and a small discount on the prices of those goods. How much these are changed is configurable via settings.

And to make access to those settings easier, an interface into Library Config was provided.

--------------------------------------------------------------

Version history:

01.06.2025 - Version 3.10   (phkb) Moved all text into missiontext.plist for easier localisation.
							Incorporated the XenonUI SW Economy Addon into this OXP, so a secondary download is not required.
							Added ability to tweak price of medicine and oxygen on harsh mining worlds.
11.03.2024 - Version 3.9.1	(phkb) Tweaked mining systems to fill their intended roll.
							Fixed issues with displaying "(m)" for mining worlds on F6 screen.
02.09.2023 - Version 3.9	(phkb) Switched to using MarketScriptInterface, and implementing changes at the commodity level, rather than using
							the shipExitedWitchspace world event. The benefit is that other internal functions to calculate market prices
							will now have all the logic applied.
							Added the option to tweak the changes via Library config.
							Further tweaks to mining worlds, boosting price of agricultural products. Also added an indicator to the chart
							screen to indicate which systems are categorised as Mining.
16.01.2021 - Version 3.8	Bundled OXP Stranger's Set reassembled in OXZ format as separate packs.
09.07.2020 - Version 3.7	Minimal planet radius for food, textiles, wines and furs production increased from 5200 to 5425 km.
12.02.2019 - Version 3.6	Fixed error in trade-goods.plist, description of firearms. Thanks, Seven!
18.08.2018 - Version 3.5	Food, textiles, wines and furs are not available in agricultural systems with main planet radius below 5200 km.
31.03.2018 - Version 3.4	Pulse laser is excluded from legal census to provide compatibility to Hard Eject OXP.
08.11.2017 - Version 3.3	Forward/aft shield ratio reverted to original 1:1 value.
06.11.2017 - Version 3.2	Improved economic rules.
				Fixed conflict with secondary markets.
				Description of secondary markets is transferred from obsolete eXternal Market Tweaks onto SW Economy package.
19.08.2017 - Version 3.1	Some readjusted player's ship specs resets to standard again.
				SW Shipdata is added as separate module.
				Injector speed factor and fuel burn rate readjusting for player and NPS ships transferred from Hard Way to Stranger Set bundle OXP.
06.07.2016 - Version 3.0	Modified In-System Market Restore script integrated into SW Economy package.
12.01.2016 - Version 2.9	Ship hull class hidden on F5 screen.
23.12.2015 - Version 2.8	Orbital Shuttle and Transporter max cargo load decreased to more realistic value.
23.10.2015 - Version 2.7	Equipment availability realised via script. Obsolete condition definitions removed.
				Script shipclassequip.js refined. Problem with ships without hyperspace capability fixed.
18.09.2015 - Version 2.6	Dredger market really fixed :-)
16.09.2015 - Version 2.5	Laser upgrade and missile re-arm available on main station only. 
15.09.2015 - Version 2.4	Fixed compatibility issue with Ore Processor 2.2.1 OXZ.
				Large Cargo Bay price reduced from 5000 to 2500 Cr.
11.09.2015 - Version 2.3	Fixed error in dredger market definition.
08.09.2015 - Version 2.2	Added brief descriptions of goods.
				Trumble opinion readjusted.
13.08.2015 - Version 2.1	Luxuries measured in kg, not tons.
				Escape Capsule cost reduced to 1000 Cr.
				Minor changes in market script.
10.08.2015 - Version 2.0	Equipment.plist moved from SW Economy to new SW Equipment OXP.
				Ship classes implemented based on hull size. Some equipment can't be installed on any ship.
				Some player's ship specs depends on hull size, max speed and energy recharge rate.
				Ship readjustments transferred to SW Equipment. SW TCS removed from bundle.
01.08.2015 - Version 1.9	Rebalanced core ship specs (test version). 
04.07.2015 - Version 1.8	External markets adjustments (more realistic profit from metals in case of dredgers for example).
27.06.2015 - Version 1.7	Market filter now covers more items.
19.06.2015 - Version 1.6	Bundle package completely reassembled.
				Markets completely redefined and converted onto Oolite 1.82 format.
				Yaw damper removed from shipdata-overrides.plist (it is realized via script in Warp Drive OXP!).
16.09.2014 - Version 1.5	Equipment.plist and shipdata-overrides.plist refined.
				Asp Mk II max roll speed increased.
05.09.2014 - Version 1.4	Price for standard and ECM-hardened missiles readjusted to improve compatibility with Missile Tweak OXP.
18.06.2014 - Version 1.3	Old readjusted ship roles and most readjusted ship specs (based on Switeck's Shipping OXP) removed from shipdata-overrides plist
				to accommodate new ship role system in Oolite 1.79.
03.06.2014 - Version 1.2	Price for Large Cargo Bay increased to 5000 Cr.
12.03.2014 - version 1.1	Fixed bug in market_tweak.js - interstellar space test.
19.11.2013 - version 1.0	Minor changes in shipdata-overrides.plist. Speeds of NPCs Cobra Mk I and Viper readjusted.
				Stranger's Tweak OXP incorporated into bundled Stranger's World package.
15.11.2013 - version 0.9	Slavery is prohibited in all ports of advanced worlds (planet ports also!).
09.07.2013 - version 0.8	Minor change in market_tweak.js. Availability of illegal goods on market depends on (tech level + government) value
				(more advanced political system has more strong market regulations).
08.06.2013 - version 0.7	Yaw damper is added to shipdata-overrides.plist (Only for Oolite basic ships!)
14.05.2013 - version 0.6	Syntax errors in shipdata-overrides.plist are corrected.
				Cobra Mk I HUD set to "hud.plist" instead "hud-small.plist" for compatibility with Gravity Well OXP.
21.03.2013 - version 0.5	Tech level availability for ECM-hardened missiles reduced from 12 to 10.
				Bug in Cobra Mk III and Python max_cargo is fixed.
22.01.2013 - Version 0.4	Added legal census for equipment availability.
				Fuel cost reduced from 10 Cr/LY to 5 Cr/LY.
15.01.2013 - Version 0.3	Script optimization.
12.01.2013 - Version 0.2	Script rewritten for Oolite 1.77
22.12.2012 - Version 0.1	Public release - compatible with Oolite 1.76.
